<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../plugins/jquery/jquery.min.js"></script>
    <script src="../js/ajaxfileupload.js"></script>
    <script src=" https://cdn.bootcss.com/jquery.form/4.2.2/jquery.form.js"></script>
</head>
<body>
<form method="post" enctype="multipart/form-data" id="imgform">
    <input type="file" name="myfile" id="myfile">
</form>

<script type="text/javascript" language="JavaScript" >

    $('#myfile').change( function() {
        $("#imgform").ajaxSubmit({
            url: "/treatment/test/upload",
            method: 'POST',
            datType: 'json',
            success: function (data) {
                console.log(data);
                if(data.imgUrl !=null){
                    alert("图片上传成功")
                }
            },
            error: function (data) {
                alert(data);
            }
        })
    })
</script>
</body>
</html>